package org.ihelpuoo.orm.handler;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.ihelpuoo.lang.ObjectUtils;
import org.ihelpuoo.orm.ObjectRule;
import org.ihelpuoo.orm.filter.FieldFilter;

public abstract class SaveNormalFieldHandler extends FieldHandler
{

	public SaveNormalFieldHandler(ObjectProcessor beanHandler)
	{
		super(beanHandler);
	}

	@Override
	protected void processWithoutExceptionHandle(ObjectRule r, Field f, Object src, Object obj,
			FieldFilter actived, FieldFilter locked, String prefix) throws Exception
	{
		Method getter = ObjectUtils.getGetter(obj.getClass(),f);
		Object v = getter.invoke(obj,(Object[])null);
		if (v != null)
			setValueToSourceObject(r,f,src,v);
	}

	protected abstract void setValueToSourceObject(ObjectRule r, Field f, Object src, Object v)
			throws Exception;

}
